package storage

import (
	"WchimeGinSystem/conf"
	"io"
)

type GetFileURLOptions struct {
	Watermark bool
}

func UploadFile(file io.Reader, file_name string, forlder_path string, ContentType string) (string, error) {
	if conf.STORAGE_TYPE == "minio" {
		return MinioUpload(file, file_name, forlder_path, ContentType)
	} else {
		return COSUpload(file, file_name, forlder_path, ContentType)
	}
}

func GetFileObject(file_name string) (any, error) {
	if conf.STORAGE_TYPE == "minio" {
		return MinioGetFile(file_name)
	} else {
		return COSGetFile(file_name)
	}
}

func GetFileURL(file_name string, opt interface{}) (string, error) {
	var watermark bool
	if opt != nil {
		if popt, ok := opt.(*GetFileURLOptions); ok {
			watermark = popt.Watermark
		}
	}
	if conf.STORAGE_TYPE == "minio" {
		return MinioGetURL(file_name)
	} else {
		return COSGetURL(file_name, watermark)
	}
}

func DelFileObject(file_name string) error {
	if conf.STORAGE_TYPE == "minio" {
		return MinioDelFile(file_name)
	} else {
		return COSDelFile(file_name)
	}
}
